#!/usr/bin/ruby -w
#coding=UTF-8
END {
   puts "Terminating Ruby Program"
}
BEGIN {
   puts "Initializing Ruby Program"
}
puts "This is main Ruby Program"

#一切皆对象
puts 3.class.class.superclass
puts 3.class.superclass.superclass
#puts Object.methods
#puts [].class

#数据类型 数组，散列，Range
ar=[1,2]
ar.push 4

a=Array.new
puts a.class
hs=Hash.new
puts hs.class

hsh={'name'=>'tzp',:sex=>'nan'}
puts hsh['name']
puts :sex #符号量
puts hsh['xx']
#引号
puts "wojiao #{hsh['name']}"

#控制语句
puts 'size == 3' if ar.size == 3
puts'size != 4' unless ar.size == 4

i=0
while i<ar.size
	puts "ar#{i}: "+ar[i].to_s
	i=i+1
end

#符号

a=[1,2,3,4]
r=(0...4) #左闭右开
puts a[r]

puts 'now is the time,'[0...-1]#掉渣了
if 0%100 == 0
  puts '%'
end